package com.raylu.realtime.utils;

import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * Description:
 * <p>
 * Create by lucienoz on 2022/1/3.
 * Copyright © 2022 lucienoz. All rights reserved.
 */
public class ThreadUtil {
    private static ThreadPoolExecutor threadPoolExecutor;

    public static ThreadPoolExecutor getInstance(){
        if (threadPoolExecutor==null) {
            synchronized (ThreadUtil.class){

                if (threadPoolExecutor==null) {
                    threadPoolExecutor = new ThreadPoolExecutor(4,50,5, TimeUnit.SECONDS,
                            new LinkedBlockingDeque<Runnable>(Integer.MAX_VALUE));
                }
            }
        }

        return threadPoolExecutor;


    }

}
